<%-- 
    Document   : checkUser
    Created on : 2019-9-18, 8:56:02
    Author     : danny
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jspf/top.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script src="js/jquery.min.js"></script>
        <script>
            $(function () {
                $('#btnCheck').click(function () {
                    $.ajax({
                        url: '${contextPath}/CheckUser',
                        data: {userName: $('#inputUserName').val()},
                        success: function (result,status,xhr) {
                            console.log(result);
                            if (result == 'true')
                                $('#tip').text('用户名已存在');
                            else
                                $('#tip').text('用户名不存在');
                        }
                    });
                });
            });
        </script>
    </head>
    <body>
        <h1>Hello World!</h1>
        <form action="CheckUser">
            <input type="text" name="userName" id="inputUserName"/><span id="tip"></span>
            <br/>
            <input type="button" value="检查" id="btnCheck"/>
        </form>
    </body>
</html>
